#!/usr/bin/perl
# diskswap.cgi in diskman

require './diskman-lib.pl';

&ReadParse();
my $diskn = $in{'disk'};
my @disks = new_get_diskinfo(); 
my ($d, $dd, $found);
$found = 0;
foreach $d (@disks){
	if($d->{'device'} eq $diskn){
		$dd = $d;
		$found = 1;
		last;
	}
}
$uid = $dd->{'status'};
$err_msg = $uid.$diskn;
#goto ERROR_OUT;
if($uid =~ /Free/) {
    `/sbin/cli64 set password=0000`;
    system("/sbin/cli64 rsf createhs drv=$diskn");
}
elsif($uid =~ /HotSpare/){
    `/sbin/cli64 set password=0000`;
    system("/sbin/cli64 rsf deletehs drv=$diskn");
}

&redirect("index.cgi");

ERROR_OUT:
&error_setup($text{'del_err_title'});
&error($err_msg);
